package com.sh.线程的创建方式;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @Auther: sh
 * @Version 1.0
 * @Description:
 */
public class 实现Callable implements Callable<String> {
    @Override
    public String call() throws Exception {
        return "这是子线程返回的结果";
    }

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        FutureTask<String> stringFutureTask = new FutureTask<>(new 实现Callable());
        Thread thread = new Thread(stringFutureTask);

        thread.start();

        String s = stringFutureTask.get();
        System.out.println(s);
    }
}

